using System;
using System.Collections.Generic;
using System.Text;
using System.Data.Common;
using System.Data;
using XBLib.Dal.AdoDal;
using DataInfo;
using KenLib.Common;
namespace KenLib.Dal
{
    public class 保有資格情報Dao : BaseAdoDao
      {
          private string m_requestTime;
          private string m_displayTime;
          public int Insert(保有資格情報 obj)
          {
              int i = 0;
              try
              {
                  m_requestTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  DbParameter param20 = _daoHelper.CreateParameter("@廃止区分", obj.廃止区分, DbType.Int16);
                  DbParameter param1 = _daoHelper.CreateParameter("@資格免許コード", obj.資格免許コード, DbType.String);
                  DbParameter param2 = _daoHelper.CreateParameter("@資格免許名", obj.資格免許名, DbType.String);
                  DbParameter param3 = _daoHelper.CreateParameter("@社内外区分", obj.社内外区分, DbType.Boolean);
                  DbParameter param4 = _daoHelper.CreateParameter("@受検年月日", obj.受検年月日, DbType.DateTime);
                  DbParameter param5 = _daoHelper.CreateParameter("@取得年月日", obj.取得年月日, DbType.DateTime);
                  DbParameter param6 = _daoHelper.CreateParameter("@社員ID", obj.社員ID, DbType.Int32);
                  DbCommand command = _daoHelper.CreateCommand(CommandNameManager.Insert_HumanDiplomaInfo, CommandType.StoredProcedure,param20, param1, param2, param3, param4, param5, param6);
                  i = _daoHelper.Execute(command);
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteLog("", "", "INSERT", "Insert_HumanDiplomaInfo", m_requestTime, m_displayTime);
              }
              catch (Exception ex)
              {
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteErr("", "", "SELECT", ex.Message, m_requestTime, m_displayTime);
              }
              return i;
          }

          public int Update(保有資格情報 obj)
          {
              int i = 0;
              try
              {
                  m_requestTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  DbParameter param20 = _daoHelper.CreateParameter("@廃止区分", obj.廃止区分, DbType.Int16);
                  DbParameter param0 = _daoHelper.CreateParameter("@ID", obj.ID, DbType.Int32);
                  DbParameter param1 = _daoHelper.CreateParameter("@資格免許コード", obj.資格免許コード, DbType.String);
                  DbParameter param2 = _daoHelper.CreateParameter("@資格免許名", obj.資格免許名, DbType.String);
                  DbParameter param3 = _daoHelper.CreateParameter("@社内外区分", obj.社内外区分, DbType.Boolean);
                  DbParameter param4 = _daoHelper.CreateParameter("@受検年月日", obj.受検年月日, DbType.DateTime);
                  DbParameter param5 = _daoHelper.CreateParameter("@取得年月日", obj.取得年月日, DbType.DateTime);
                  DbParameter param6 = _daoHelper.CreateParameter("@社員ID", obj.社員ID, DbType.Int32);
                  DbCommand command = _daoHelper.CreateCommand(CommandNameManager.Update_HumanDiplomaInfo, CommandType.StoredProcedure,param20, param0, param1, param2, param3, param4, param5, param6);
                  i = _daoHelper.Execute(command);
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteLog("", "", "UPDATE", "Update_HumanDiplomaInfo", m_requestTime, m_displayTime);
              }
              catch (Exception ex)
              {
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteErr("", "", "SELECT", ex.Message, m_requestTime, m_displayTime);
              }
              return i;
          }

          public int Delete(int id)
          {
              int i = 0;
              try
              {
                  m_requestTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  DbParameter param0 = _daoHelper.CreateParameter("@ID", id, DbType.Int32);

                  DbCommand command = _daoHelper.CreateCommand(CommandNameManager.Delete_HumanDiplomaInfo, CommandType.StoredProcedure, param0);
                  i = _daoHelper.Execute(command);
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteLog("", "", "DELETE", "Delete_HumanDiplomaInfo", m_requestTime, m_displayTime);
              }
              catch (Exception ex)
              {
                  m_displayTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                  ExportFile.WriteErr("", "", "SELECT", ex.Message, m_requestTime, m_displayTime);
              }
              return i;
		  }

		  #region Hunglt
		  public DataTable Select資格免許()
          {
              DbCommand command = _daoHelper.CreateCommand("sp_select_資格免許_Hunglt", CommandType.StoredProcedure);
              return _daoHelper.Query(command);
          }

          public string Insert保有資格情報(保有資格情報 obj)
          {
              try
              {
                  DbParameter param廃止区分 = _daoHelper.CreateParameter("@廃止区分", obj.廃止区分, DbType.Int16);
                  DbParameter param資格免許コード = _daoHelper.CreateParameter("@資格免許コード", obj.資格免許コード, DbType.String);
                  DbParameter param資格免許名 = _daoHelper.CreateParameter("@資格免許名", obj.資格免許名, DbType.String);
                  DbParameter param社内外区分 = _daoHelper.CreateParameter("@社内外区分", obj.社内外区分, DbType.Boolean);
                  DbParameter param受検年月日 = _daoHelper.CreateParameter("@受検年月日", obj.受検年月日, DbType.DateTime);
                  DbParameter param取得年月日 = _daoHelper.CreateParameter("@取得年月日", obj.取得年月日, DbType.DateTime);
                  DbParameter param社員ID = _daoHelper.CreateParameter("@社員ID", obj.社員ID, DbType.Int32);

                  DbCommand command = _daoHelper.CreateCommand("sp_Insert_FrmO_EmpDiplomaInput_Hunglt", CommandType.StoredProcedure,
                      param廃止区分, param資格免許コード, param資格免許名, param社内外区分, param受検年月日, param取得年月日, param社員ID);
				  return _daoHelper.ExecuteScalar(command).ToString();
              }
              catch (Exception)
              {
                  
                  throw;
              }
		  }

		  public void UpdateInfo保有資格情報_ByID(保有資格情報 obj, int ID)
		  {
			  try
			  {
				  DbParameter param廃止区分 = _daoHelper.CreateParameter("@廃止区分", obj.廃止区分, DbType.Int16);
				  DbParameter param資格免許コード = _daoHelper.CreateParameter("@資格免許コード", obj.資格免許コード, DbType.String);
				  DbParameter param資格免許名 = _daoHelper.CreateParameter("@資格免許名", obj.資格免許名, DbType.String);
				  DbParameter param社内外区分 = _daoHelper.CreateParameter("@社内外区分", obj.社内外区分, DbType.Boolean);
				  DbParameter param受検年月日 = _daoHelper.CreateParameter("@受検年月日", obj.受検年月日, DbType.DateTime);
				  DbParameter param取得年月日 = _daoHelper.CreateParameter("@取得年月日", obj.取得年月日, DbType.DateTime);
				  DbParameter param社員ID = _daoHelper.CreateParameter("@社員ID", obj.社員ID, DbType.Int32);
				  DbParameter dbParamID = _daoHelper.CreateParameter("@ID", ID, DbType.Int32);

				  DbCommand command = _daoHelper.CreateCommand("sp_Update_FrmO_EmpDiplomaInput_Hunglt", CommandType.StoredProcedure,
					  param廃止区分, param資格免許コード, param資格免許名, param社内外区分, param受検年月日, param取得年月日, param社員ID, dbParamID);
				  _daoHelper.Execute(command);
			  }
			  catch (Exception)
			  {
				  throw;
			  }
		  }

		  public DataTable SelectInfo保有資格情報_ByID(int ID, int 社員ID)
		  {
			  DbParameter paramID = _daoHelper.CreateParameter("@ID", ID, DbType.Int32);
			  DbParameter param社員ID = _daoHelper.CreateParameter("@社員ID", 社員ID, DbType.Int32);
			  DbCommand command = _daoHelper.CreateCommand("sp_select_保有資格情報_FormO_Hunglt", CommandType.StoredProcedure, paramID, param社員ID);
			  return _daoHelper.Query(command);
		  }

		  public int CheckExist社員ID_frmO_EmpDiplomaInput(int 企業ID, int 社員ID, out int Result) 
		  {
			  int i = -1;
			  DbParameter param企業ID = _daoHelper.CreateParameter("@企業ID", 企業ID, DbType.Int16);
			  DbParameter param社員ID = _daoHelper.CreateParameter("@社員ID", 社員ID, DbType.Int32);
			  DbParameter paramResult = _daoHelper.CreateParameter("@result", i);
			  paramResult.Direction = ParameterDirection.Output;

			  DbCommand command = _daoHelper.CreateCommand("sp_CheckExist_FrmO_EmpDiplomaInput_Hunglt", CommandType.StoredProcedure,
				  param企業ID, param社員ID, paramResult);
			  _daoHelper.Execute(command);
			  Result = (int)command.Parameters["@result"].Value;
			  return i;
		  }

		  public DataTable SelectData保有資格情報(int 社員ID)
		  {
			  DbParameter param社員ID = _daoHelper.CreateParameter("@社員ID", 社員ID, DbType.Int32);
			  DbCommand command = _daoHelper.CreateCommand("sp_Select_保有資格情報_Hunglt", CommandType.StoredProcedure, param社員ID);
			  return _daoHelper.Query(command);
		  }
		  #endregion

		  /// <summary>
            /// Coder: VanHoat
            /// </summary>
            /// <param name="obj"></param>
            /// <returns>List</returns>
            /// 
          //public DataTable SelectPartial保有資格情報(String 社員ID, int startRow, int numRecord)
          //{
          //    DbCommand com = _daoHelper.CreateCommand(CommandNameManager.sp_Select保有資格情報_Partial_12, CommandType.StoredProcedure);
          //    DbParameter para1 = _daoHelper.CreateParameter("@社員ID", 社員ID);
          //    DbParameter para2 = _daoHelper.CreateParameter("@currentPage", startRow);
          //    DbParameter para3 = _daoHelper.CreateParameter("@numRecord", numRecord);
          //    com.Parameters.Add(para1);
          //    com.Parameters.Add(para2);
          //    com.Parameters.Add(para3);

          //    return _daoHelper.Query(com);
          //}  
        public DataTable SelectPartial保有資格情報(String 社員ID)
          {
              DbCommand com = _daoHelper.CreateCommand(CommandNameManager.sp_Select保有資格情報_Partial_12, CommandType.StoredProcedure);
              DbParameter para1 = _daoHelper.CreateParameter("@社員ID", 社員ID);
              
              com.Parameters.Add(para1);
            
              return _daoHelper.Query(com);
          }
        #region Mai
        public DataTable ShowGrid保有資格情報(int 社員ID)
        {
            DbParameter param = _daoHelper.CreateParameter("@社員ID", 社員ID, DbType.Int32);
            DbCommand dbcommand = _daoHelper.CreateCommand("sp_frmJ_TraineeDiplomaInput_ShowGrid保有資格情報_Mai", CommandType.StoredProcedure, param);
            return _daoHelper.Query(dbcommand);
        }
        public void Insert_frmJ_TraineeDiplomaInput(保有資格情報 obj)
        {
            DbParameter param0 = _daoHelper.CreateParameter("@資格免許コード", obj.資格免許コード1, DbType.Int32);
            DbParameter param6 = _daoHelper.CreateParameter("@資格免許名", obj.資格免許名, DbType.String);
            DbParameter param1 = _daoHelper.CreateParameter("@社内外区分", obj.社内外区分, DbType.Boolean);
            DbParameter param2 = _daoHelper.CreateParameter("@受検年月日", obj.受検年月日, DbType.DateTime);
            DbParameter param3 = _daoHelper.CreateParameter("@取得年月日", obj.取得年月日, DbType.DateTime);
            DbParameter param4 = _daoHelper.CreateParameter("@社員ID", obj.社員ID, DbType.Int32);
            DbParameter param5 = _daoHelper.CreateParameter("@廃止区分", obj.廃止区分, DbType.Int16);
            DbCommand dbcommand = _daoHelper.CreateCommand("sp_frmJ_TraineeDiplomaInput_Insert保有資格情報_Mai", CommandType.StoredProcedure, param0, param1, param2, param3, param4, param5, param6);
            _daoHelper.Execute(dbcommand);
        }
        public void Update_frmJ_TraineeDiplomaInput(保有資格情報 oj)
        {
            DbParameter param = _daoHelper.CreateParameter("@資格免許コード", oj.資格免許コード1, DbType.Int32);
            DbParameter param5 = _daoHelper.CreateParameter("@資格免許名", oj.資格免許名, DbType.String);
            DbParameter param1 = _daoHelper.CreateParameter("@社内外区分", oj.社内外区分, DbType.Boolean);
            DbParameter param2 = _daoHelper.CreateParameter("@受検年月日", oj.受検年月日, DbType.DateTime);
            DbParameter param3 = _daoHelper.CreateParameter("@取得年月日", oj.取得年月日, DbType.DateTime);
            DbParameter param4 = _daoHelper.CreateParameter("@ID", oj.ID, DbType.Int32);
            DbCommand dbcommand = _daoHelper.CreateCommand("sp_frmJ_TraineeDiplomaInput_Update保有資格情報_Mai", CommandType.StoredProcedure, param, param1, param2, param3, param4, param5);
            _daoHelper.Query(dbcommand);
        }
        #endregion

      }
}
